package com.station.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.station.entity.CommonPayRecord;
import com.station.service.CommonPayRecordService;
import com.station.service.mapper.CommonPayRecordMapper;
import com.station.vo.CommonPayRecordVo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @ClassName:PayInfoServiceImpl
 * @Description:
 * <p>支付信息服务类</p>
 * @author:admin
 */
@Service
public class CommonPayRecordImpl extends BaseServiceImpl<CommonPayRecordMapper, CommonPayRecord> implements CommonPayRecordService  {
	/**注入dao*/
	@Autowired
	private CommonPayRecordMapper commonPayRecordMapper;
	@Value("${rd.bld.token}")
	@Getter
	@Setter
	private String bldToken;
	@Value("${rd.bld.vendorId}")
	@Getter
	@Setter
	private String bldVendorId;
	@Value("${rd.epc.bldOrderUrl}")
	@Getter
	@Setter
	private String bldOrderUrl;


	@Override
	public CommonPayRecord queryCommonPayRecord(CommonPayRecordVo commonPayRecordVo) {
		LambdaQueryWrapper<CommonPayRecord> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CommonPayRecord::getChannelType,commonPayRecordVo.getChannelType());
		queryWrapper.eq(CommonPayRecord::getChannelOrderId,commonPayRecordVo.getChannelOrderId());
		queryWrapper.eq(CommonPayRecord::getPayType,commonPayRecordVo.getPayType());
		queryWrapper.eq(CommonPayRecord::getStatus,commonPayRecordVo.getStatus());
		CommonPayRecord commonPayRecord = commonPayRecordMapper.selectOne(queryWrapper);
		return commonPayRecord;
	}

	@Override
	public boolean save(CommonPayRecord entity) {
		return super.save(entity);
	}

	@Override
	public CommonPayRecord queryByPayId(String payId) {
		LambdaQueryWrapper<CommonPayRecord> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CommonPayRecord::getPayid,payId);
		CommonPayRecord commonPayRecord = commonPayRecordMapper.selectOne(queryWrapper);
		return commonPayRecord;
	}

	@Override
	public CommonPayRecord queryByMerchantOrderId(String orgTrace) {
		LambdaQueryWrapper<CommonPayRecord> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CommonPayRecord::getMerchantOrderId, orgTrace);
		CommonPayRecord commonPayRecord = commonPayRecordMapper.selectOne(queryWrapper);
		return commonPayRecord;
	}

	@Override
	public CommonPayRecord queryByChannelOrderId(String channelOrderId) {
		LambdaQueryWrapper<CommonPayRecord> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(CommonPayRecord::getChannelOrderId,channelOrderId);
		CommonPayRecord commonPayRecord = commonPayRecordMapper.selectOne(queryWrapper);
		return commonPayRecord;
	}

	@Override
	public int update(CommonPayRecord commonPayRecord) {
		return commonPayRecordMapper.updateById(commonPayRecord);
	}


}
